package ma.jee.portailReservation.service.announce.Impl;

import ma.jee.portailReservation.persistence.announce.Announce;
import ma.jee.portailReservation.persistence.announce.IAnnounceDAO;
import ma.jee.portailReservation.service.announce.DisplayAnnounce;
import ma.jee.portailReservation.service.announce.IDisplayAnnounceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 02/01/12
 * Time: 23:38
 * To change this template use File | Settings | File Templates.
 */
@Service("defaultDisplayAnnounceService")
public class DefaultDisplayAnnounceService implements IDisplayAnnounceService{

    @Autowired
	@Qualifier("hibernateAnnounceDAO")
	private IAnnounceDAO announceDAO;

    @Override
    @Transactional(readOnly=true)
    public List<DisplayAnnounce> getAllDisplayAnnounces() {

         List<DisplayAnnounce> result = new ArrayList< DisplayAnnounce >();

        for(Announce announce : announceDAO.findAll()) {
                  result.add(new DisplayAnnounce(announce));
        }

        return result;
    }
}
